/*
 * Deptree.h
 *
 *  Created on: Dec 18, 2014
 *      Author: Phong
 */

#ifndef DEPTREE_H_
#define DEPTREE_H_

#include "Dictionary.h"
#include <string>
#include "Matrix.h"
#include <vector>
#include "SafeShare.h"
using namespace std;

class Depstruct;

class Deptree : public SafeShare {
public:
	int nNodes;
	int *word, *pos, *parent, *dir, *deprel;
	int** nChildren;
	int*** children;
	int** wordCands;
	Depstruct* ds;

	// temp arrays for training + parsing
	Matrix** gRep;
	Matrix** pGRep;
	Matrix** priorPGRep;
	Matrix** gradPriorPGRep;
	Matrix*** EOCGRep;
	Matrix*** priorEOCGRep;
	Matrix*** gradPriorEOCGRep;
	Matrix** gradGRep;
	Matrix** gradpGRep;
	Matrix*** gradEOCGRep;

	Matrix** gradheadRep;
	Matrix** gradCRep;
	Matrix** headRep;
	Matrix** cRep;

	Matrix** deprelProb;
	Matrix** posProb;
	Matrix** wordProb;
	Matrix*** EOCProb;

	Deptree(int nWords);
	Deptree* clone(bool cloneRep = false);

	void freeTempArrays();

	string toString(Dictionary* vocaDic, Dictionary* posDic, Dictionary* deprelDic);

	void getSentence(Dictionary* vocaDic, Dictionary* posDic, Dictionary* deprelDic, vector<string>& sentence);
	void getSentence(Dictionary* vocaDic, Dictionary* posDic, Dictionary* deprelDic, vector<string>& sentence, int &curid, int headid = -1, int node = 0);

protected:
	virtual ~Deptree();
};

#endif /* DEPTREE_H_ */
